package cn.krund.lyc.hotlerobot.activity.ui;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import cn.krund.lyc.hotlerobot.R;
import cn.krund.lyc.hotlerobot.utils.Constant;
import cn.krund.lyc.hotlerobot.xunfei.XunfeiAlternate;

public class MainActivity extends Activity implements View.OnClickListener{
    private XunfeiAlternate mXunfeiAlternate;
    private Button btn_1,btn_2;
    private String[] speak= Constant.speak;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        mXunfeiAlternate=XunfeiAlternate.getInstance();
    }

    private void initView() {
            btn_1= (Button) findViewById(R.id.btn_1);
            btn_2= (Button) findViewById(R.id.btn_2);
            btn_2.setOnClickListener(this);
            btn_1.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
            switch (v.getId()){
                case R.id.btn_1:
                    mXunfeiAlternate.speak("阿克苏季度会对我");
                    break;
                case R.id.btn_2:
                    mXunfeiAlternate.speak(getAwakeAnswer(speak));
                    break;
            }
    }
    /**
     * 获取随机回答
     *
     * @return
     */
    public String getAwakeAnswer(String[] txt) {
        int num = (int) (Math.random() * txt.length);
        return txt[num];
    }
}
